<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SMS - Swing Modulo Scheduling in GCC</title>
<link rel="stylesheet" type="text/css" href="https://gcc.gnu.org/gcc.css" />
</head>

<body>
<h1>SMS - Swing Modulo Scheduling in GCC</h1>

<p>February 2005</p>

<p>We are pleased to announce that Mostafa Hagog and Ayal Zaks, of
IBM Haifa Labs, have contributed
Swing Modulo Scheduling (SMS) to GCC 4.0. Their implementation is based 
on the articles:</p>
<ul>
  <li>Lifetime--sensitive modulo scheduling in a production environment.
      IEEE Trans. on Comps., 50(3), March 2001.
      J. Llosa, A. Gonzalez, E. Ayguade, M. Valero., and J. Eckhardt. </li>
  <li>Josep Llosa,Antonio Gonzalez, Eduard Ayguade, and Mateo Valero.
      Swing Modulo Scheduling: A Lifetime Sensitive Approach.
      In Pact96 , pages 80-87, October 1996 
      (Boston - Massachusetts - USA).</li>
</ul>


<p>SMS is intended to schedule instructions of loops rather than the
traditional scheduler (in GCC) that does not give a special
handling for loops. For more information on the theory behind
SMS take a look at the <a href=
"https://gcc.gnu.org/pub/gcc/summit/2004/Swing%20Modulo%20Scheduling.pdf">
2004 GCC summit proceedings (page 55)</a>.
This optimization helps in loops where there is a place to
run consecutive iterations concurrently but the traditional
instruction scheduling is not able to fully utilize the hardware
functional units.  This optimization is disabled by default
because of compile time consumption; <code>-fmodulo-sched</code> 
activates it. The current implementation of SMS is preliminary  
and is not effective in the following cases:</p>
<ul>
  <li>Loops that have stores to memory.</li>
  <li>High register pressure and poor register set.</li>
  <li>Architectures that do not have a BCT (Branch on Count)
      instructions.</li>
  <li>out-of-order machines; SMS impact is more noticeable on
      in-order machines (out-of-order machines do this work
      in hardware).</li>
</ul>

<p>Improvements to SMS to overcome (but not only) the first
three restrictions are expected in the coming releases of GCC.</p>

</body>
</html>
